﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using ObviousCode.Aspect.PluginLibrary.Abstract;
using ObviousCode.Common.Utils.Library.Dictionaries;
using ObviousCode.UI.Aspect.PluginLibrary.Resources;

namespace ObviousCode.Aspect.PluginLibrary
{
    public class ChartObjectImages
    {
        public Image Icon { get; set; }
        
        Image _treeImage;
        Image _selectedImage;
        Image _unselectedImage;
        Image _dragImage;

        string _treeImageKey;        

        public ChartObjectImages()
        {
            Icon = DefaultAspectImages.DefaultChartImage;
        
            _treeImage = DefaultAspectImages.DefaultTreeImage;
            _treeImageKey = "default";
            
            UseDragImage = false;
        }

        public bool UseDragImage { get; set; }

        public void AddTreeImage(string key, Image treeImage)
        {
            _treeImage = treeImage;
            _treeImageKey = key;
        }

        public Image TreeImage
        {
            get { return _treeImage ?? Icon; }            
        }

        public string TreeImageKey
        {
            get { return _treeImageKey; }            
        }

        public System.Drawing.Image SelectedImage
        {
            get { return _selectedImage ?? Icon; }
            set { _selectedImage = value; }
        }

        public System.Drawing.Image UnselectedImage
        {
            get { return _unselectedImage ?? Icon; }
            set { _unselectedImage = value; }
        }

        public System.Drawing.Image DragImage
        {
            get { return UseDragImage ? null : (_dragImage ?? Icon); }
            set { _treeImage = value; }
        }

        public PropertyDictionary Persist()
        {
            PropertyDictionary dictionary = new PropertyDictionary();

            dictionary.Set("tree-image-key", TreeImageKey);

            return dictionary;
        }
    }
}
